<?php 
	session_start(); 
	if (!$_SESSION["id_no"])
    {
        Header("Location: index.php");
    }
	else{
		if ($_SESSION['account_type']=='root'){
			$header="secured/header_login";
		}
		else{ 
			$header="header";
		}
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Ralimo System Panel</title>
<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" title="default" />
<link rel="stylesheet" href="css/jquery-ui-1.8.21.custom.css" type="text/css" media="screen" title="default" />
<!--[if IE]>
<link rel="stylesheet" media="all" type="text/css" href="css/pro_dropline_ie.css" />
<![endif]-->
<!--  jquery core -->
<script src="js/jquery/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
<!--  date picker script -->
<link rel="stylesheet" href="css/datePicker.css" type="text/css" />
<script type="text/javascript" src="js/jquery/infowindow.js"></script>
<script type="text/javascript" src="js/jquery/geocoder.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#map_canvas").hide();
		initializeGeoCoder();
		/*$("#update_user").validate({
			debug: false,
			rules:{
				username:"required",
				user_address:"required",
				email:"required",
				contact_no:"required"
			},
			submitHandler: function(form){
				$.post("query/update_users.php", $("#update_user").serialize(), function(data){
					window.location.replace("panel.php?page=manage_user");
				});
			}
		});*/
	
	});
	$(function(){
		$("#edit_address").autocomplete({
			source: function(request, response){
				geocoder.geocode( {'address': request.term}, function(results, status){
					response($.map(results, function(item){
						var arr = item.formatted_address.split(",");
						return {
							label:  item.formatted_address,
							value:  $.trim(arr[0]),
							country: $.trim(arr[arr.length-1]),
							latitude: item.geometry.location.lat(),
							longitude: item.geometry.location.lng()
						}
					}));
				})
			},
		
		});
	 });
</script>
</head>
<body> 
<?php 
	include"template/$header.php"; 
	include("query/db_connection.php");
	
	if(isset($_POST['button'])){
		require("query/db_connection.php");
		
		$id 		  = $_POST['users_id'];
		$username 	  = $_POST['username'];
		$account_type = $_POST['account_type'];
		$user_address = $_POST['edit_address'];
		$email		  = $_POST['email'];
		$contact_no	  = $_POST['contact_no'];
		
		$sql = "UPDATE user SET user= '$username', account_type='$account_type', address='$user_address', email='$email', contact_no='$contact_no'
				WHERE user_id = '$id'";
		mysql_query($sql);
		
		echo "<script type='text/javascript'>
				window.location.replace('panel.php?page=manage_user');
			 </script>";
	}

?>
  <div class='clear'></div>
<!-- start content-outer ........................................................................................................................START -->
	<div id='content-outer'>
	<!-- start content -->
	<div id='content'>

	<!--  start page-heading -->
	<div id='page-heading'>
		<h1>Edit User</h1>
	</div>
	
	<!-- end page-heading -->
	<div id="back_affiliate"  style="margin-left:1140px; width:100px;">
		<a href="panel.php?page=manage_user"><img src="images/forms/back.png" /></a>
	</div>

	<table border='0' width='100%' cellpadding='0' cellspacing='0' id='content-table'>
	<tr>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowleft.jpg' width='20' height='300' alt='' /></th>
		<th class='topleft'></th>
		<td id='tbl-border-top'>&nbsp;</td>
		<th class='topright'></th>
		<th rowspan='3' class='sized'><img src='images/shared/side_shadowright.jpg' width='20' height='300' alt='' /></th>
	</tr>
	<tr>
		<td id='tbl-border-left'></td>
		<td>
		<!--  start content-table-inner ...................................................................... START -->
		<div id='content-table-inner'>
						<!--  start step-holder -->
			<div id="step-holder">
				<div id="map_canvas"></div>
				<div class="step-dark-left"><a href="">Edit User</a></div>
				<div class="step-dark-round">&nbsp;</div>
				<div class="clear"></div>
			</div>
		<!--  end step-holder -->
		
			<!--  start table-content  -->
			<div id='table-content'>
				<form action="" method="post">
						<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
							<tr>
								<th valign="top">Username:</th>
								<td><input type="text" id="username" name="username" autocomplete="off" class="inp-form" value="<?php echo $_GET['user'];?>"/></td>
							</tr>
							<tr>
								<th valign="top">Account Type:</th>
								<td>
									<select id="account_type" name="account_type" style="width:190px; height:38px; padding:10px;" >
										<?php
											if($_GET['account'] == 'Admin'){
												echo "<option selected='selected' >Admin</option>";
												echo "<option >User</option>";
											}else{
												echo "<option >Admin</option>";
												echo "<option selected='selected' >User</option>";
											}
										?>
									</select>
								</td>
							</tr>
							<tr>
								<th valign="top">Address:</th>
								<td><input type="text" id="edit_address" name="edit_address" autocomplete="off" class="inp-form" value="<?php echo $_GET['address'];?>" /></td>
							</tr>
							<tr>
							<tr>
								<th valign="top">Email:</th>
								<td><input type="text" id="email" name="email" autocomplete="off" class="inp-form" value="<?php echo $_GET['email'];?>" /></td>
							</tr>
							<tr>
								<th valign="top">Contact No:</th>
								<td><input type="text" id="contact_no" name="contact_no" autocomplete="off" class="inp-form" value="<?php echo $_GET['contact'];?>"/></td>				
							</tr>							
							<tr>
								<th>&nbsp;</th>
								<td valign="top">
									<input id="button" name="button" type="submit" class="form_update" />
									<input type="hidden" name="users_id" value="<?php echo $_GET['id'];?>" />
								</td>
								<td></td>
							</tr>
					</table>
				</form>
			</div>
			<!--  end table-content  -->
	
			<div class='clear'></div>
		 
		</div>
		<!--  end content-table-inner ............................................END  -->
		</td>
		<td id='tbl-border-right'></td>
	</tr>
	<tr>
		<th class='sized bottomleft'></th>
		<td id='tbl-border-bottom'>&nbsp;</td>
		<th class='sized bottomright'></th>
	</tr>
	</table>
	<div class='clear'>&nbsp;</div>

	</div>
	<!--  end content -->
	<div class='clear'>&nbsp;</div>
	</div>
	<!--  end content-outer........................................................END -->";
				
<!--  start nav-outer-repeat................................................... END -->

  <div class="clear"></div>
 
<!-- start content-outer ........................................................................................................................START -->
<div id="content-outer">
<!-- start content -->
<!--  end content -->
<div class="clear">&nbsp;</div>
</div>
<!--  end content-outer........................................................END -->

<div class="clear">&nbsp;</div>
    
<?php include"template/footer.php"; ?>
 
</body>
</html>


